package jcrweb.as3
{
	public class FlexUtil
	{
			
		public static var ERROR_CODE_TAG:String = "error_code";
		
		public static var ERROR_MES_TAG:String = "error_message";
		
		public static var RESULT_SIZE:String = "result_size";
		
		public static var RESULT_DATA:String = "result_data";
		
		public static var IS_ERROR:String = "is_error";// return yes or no 
		
		public static function getTag(srcStr:String,tagStr:String):String{
			if(srcStr.indexOf("<"+tagStr+">") == -1){
				return "";
			}
			var startIndex:int = srcStr.indexOf("<"+tagStr+">") + tagStr.length + 2;
			var endIndex:int = srcStr.indexOf("</"+tagStr+">");
			var strDatas:String = srcStr.substring(startIndex,endIndex);
			return strDatas;
		}
		public static function getUpPath(path:String):String{
			if((path == null || path.length == 0) || path == "/"){
				return "/";
			}
			if(path.substring(0,1) == "/"){
				path = path.substring(1);
			}
			var paths:Array = path.split("/");
			var overpath:String = "";
			var med:String = "";
			for(var i:int=0;i<paths.length;i++){
				var strPath:String = "";
				if(i == 0){
					strPath = "/"+paths[i];
				}else{
					strPath = med+"/"+paths[i];
				}
				med = med+"/"+paths[i];
				if((i+1) == paths.length-1){
					overpath = strPath;
				}
			}
			return overpath;
		}
		public static function randomURL(strUrl:String):String{
			return strUrl+"&r="+Math.random();
		}
	}
}